import { useEffect,useState } from 'react'

// http://geek.itheima.net/v1_0/channels
const URL = 'http://geek.itheima.net/v1_0/channels'

function App() {

  const [list, setList]= useState([])

  useEffect(() => {
    async function fetchData() {
      const response = await fetch(URL)
      const data = await response.json()
      console.log(data)
      setList(data.data.channels)
    }
    fetchData()
  }, [])



  return (
    <div>
      <h1>This is APP :useEffect</h1>
      <ul>
        {
          list.map(item => <li key={item.id}>{item.name}</li>)
        }
      </ul>
    </div>
  )
}

export default App;